home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL2.toast / What's New / Software Development Kits / MacOS USB DDK / Examples / PrinterClassDriver / SafeNameRegistry.cp < prev    next >
Encoding:
Text File  |  1998-07-20  |  21.1 KB  |  665 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SafeNameRegistry.cp
  3.  
  4.     Contains:    Stub routines for name registry calls
  5.  
  6.     Think of the Name Registry as a database used by System software 
  7.     to keep track of hardware and other settings. Its up to the 
  8.     indivdual software (called expert software) to insert and remove 
  9.     entries from the Name Registry. The information contained inside 
  10.     the entries can be whatever the expert software deems important.
  11.  
  12.     The Name Registry is only available on PCI based Macs. The Name
  13.     Registry routines reside in a PPC shared library (there isn't a
  14.     68K version), hence the need for these stub routines. When we build
  15.     fat drivers there is a chance on a PPC of running the 68K version
  16.     of the driver. Therefore we needed a way of calling into the Name
  17.     Registry shared library from 68K code. These routines will load the
  18.     Name Registry library and create procptrs for the needed calls. The
  19.     same stub calls will work on PPC and 68K
  20.  
  21.     Copyright:    © 1998 by Apple Computer, Inc., all rights reserved.
  22.  
  23. */
  24.  
  25. #ifndef __Chooser__
  26. #include "Chooser.h"
  27. #endif
  28.  
  29. #ifndef __CODEFRAGMENTS__
  30. #include <CodeFragments.h>
  31. #endif
  32.  
  33. #ifndef __MIXEDMODE__
  34. #include <MixedMode.h>
  35. #endif
  36.  
  37. #ifndef __GESTALT__
  38. #include <Gestalt.h>
  39. #endif
  40.  
  41. #ifndef __ERRORS__
  42. #include <Errors.h>
  43. #endif
  44.  
  45. #ifndef __DIALOGS__
  46. #include <Dialogs.h>
  47. #endif
  48.  
  49. #ifndef __SafeNameRegistry__
  50. #include "SafeNameRegistry.h"
  51. #endif
  52.  
  53. /******************************************************************************
  54.     Prototypes
  55.  ******************************************************************************/
  56.  
  57. // prototypes used to find address of routine in name registry library
  58. OSErr FindAddress(Ptr* pSymAddr, Str255 pSymName, ProcInfoType pProcInfo);
  59. pascal OSErr GetSystemArchitecture(OSType *archType);
  60.  
  61. /******************************************************************************
  62.     Typedefs
  63.  ******************************************************************************/
  64.  
  65. // proc typedefs for calling routines in the name registry library
  66. typedef pascal OSStatus (*RegistryEntryIDInitProcPtr) ( RegEntryID* id );
  67. typedef pascal OSStatus (*RegistryCStrEntryLookupProcPtr) ( RegEntryID* searchPointID, 
  68.             RegCStrPathName* pathName, RegEntryID*foundEntry );
  69. typedef pascal OSStatus (*RegistryEntryIterateCreateProcPtr) ( RegEntryIter* cookie );
  70. typedef pascal OSStatus (*RegistryEntryIterateDisposeProcPtr) ( RegEntryIter* cookie );
  71. typedef pascal OSStatus (*RegistryEntryIterateSetProcPtr) ( RegEntryIter* cookie, RegEntryID *startEntryID );
  72. typedef pascal OSStatus (*RegistryEntryIterateProcPtr) ( RegEntryIter *cookie, 
  73.             RegEntryIterationOp relationship, RegEntryID *foundEntry, Boolean *done );
  74. typedef pascal OSStatus (*RegistryEntryIDDisposeProcPtr) ( RegEntryID* id );
  75. typedef pascal OSStatus (*RegistryPropertyGetProcPtr) ( RegEntryID *entryID, 
  76.             RegPropertyName *propertyName, void *propertyValue, RegPropertyValueSize *propertySize );
  77.  
  78. /******************************************************************************
  79.     Constants
  80.  ******************************************************************************/
  81.  
  82. #define    kNoNameRegistryAlert        3000
  83.  
  84. // stack descriptors used in the name registry stub calls to pass params
  85. // to the proper routine in the name registry shared library
  86.  
  87. enum {
  88.     kRegistryEntryIDInitProcInfo = kPascalStackBased
  89.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  90.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  91. };
  92. enum {
  93.     kRegistryCStrEntryLookupProcInfo = kPascalStackBased
  94.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  95.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  96.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegCStrPathName*)))
  97.     | STACK_ROUTINE_PARAMETER( 3, SIZE_CODE(sizeof( RegEntryID*)))
  98. };
  99. enum {
  100.     kRegistryEntryIterateCreateProcInfo = kPascalStackBased
  101.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  102.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  103. };
  104. enum {
  105.     kRegistryEntryIterateDisposeProcInfo = kPascalStackBased
  106.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  107.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  108. };
  109. enum {
  110.     kRegistryEntryIterateSetProcInfo = kPascalStackBased
  111.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  112.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  113.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegEntryID*)))
  114. };
  115. enum {
  116.     kRegistryEntryIterateProcInfo = kPascalStackBased
  117.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  118.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryIter*)))
  119.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegEntryIterationOp)))
  120.     | STACK_ROUTINE_PARAMETER( 3, SIZE_CODE(sizeof( RegEntryID*)))
  121.     | STACK_ROUTINE_PARAMETER( 4, SIZE_CODE(sizeof( Boolean*)))
  122. };
  123. enum {
  124.     kRegistryEntryIDDisposeProcInfo = kPascalStackBased
  125.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  126.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  127. };
  128. enum {
  129.     kRegistryPropertyGetProcInfo = kPascalStackBased
  130.     | RESULT_SIZE( SIZE_CODE(sizeof(OSStatus)))
  131.     | STACK_ROUTINE_PARAMETER( 1, SIZE_CODE(sizeof( RegEntryID*)))
  132.     | STACK_ROUTINE_PARAMETER( 2, SIZE_CODE(sizeof( RegPropertyName*)))
  133.     | STACK_ROUTINE_PARAMETER( 3, SIZE_CODE(sizeof( void*)))
  134.     | STACK_ROUTINE_PARAMETER( 4, SIZE_CODE(sizeof( RegPropertyValueSize*)))
  135. };
  136.  
  137. /*-----------------------------------------------------------------------------*
  138.  
  139.     NameRegistryInstalled
  140.     
  141.     Desc:        Test to see if the name registry exists on this machine
  142.  
  143.     In:            None
  144.  
  145.     Out:        True if name registry exists else false
  146.     
  147.     History:
  148.  
  149.     18 Mar 98    gp        Added.
  150.     
  151. *-----------------------------------------------------------------------------*/
  152. Boolean    NameRegistryInstalled( void )
  153. {
  154.     OSErr    err=noErr;        // result from gestalt call
  155.     long    result;
  156.     USBGlobalsHandle    gGlobals=nil;        // our global data area
  157.  
  158.     gGlobals = GetGlobalStorage();
  159.  
  160.     // if not our first time then return previous result
  161.     if( (**gGlobals).checkedForNameRegistry == true )
  162.         return (**gGlobals).hasNameRegistry;
  163.     else {
  164.  
  165.     // check to see if name registry exists
  166.         err = Gestalt(gestaltNameRegistryVersion, &result);
  167.         if( err == noErr )
  168.             (**gGlobals).hasNameRegistry = true;
  169.         else {
  170.             (**gGlobals).hasNameRegistry = false;
  171.     // put up alert if it isn't installed
  172.             StopAlert(kNoNameRegistryAlert, nil);
  173.         }
  174.         (**gGlobals).checkedForNameRegistry=true;
  175.     }
  176.     return (**gGlobals).hasNameRegistry;
  177. }
  178.  
  179. /*-----------------------------------------------------------------------------*
  180.  
  181.     SafeRegistryEntryIDInit
  182.     
  183.     Desc:        Stub code for name registry routine 'RegistryEntryIDInit'
  184.  
  185.     In:            id - pointer to a RegEntryID to initialize
  186.  
  187.     Out:        returns any errors which may have occur
  188.     
  189.     History:
  190.  
  191.     18 Mar 98    gp        Added.
  192.     
  193. *-----------------------------------------------------------------------------*/
  194.  
  195. OSStatus SafeRegistryEntryIDInit(RegEntryID *id)
  196. {
  197.     OSStatus    anErr=-1;                // return value
  198.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  199.  
  200.     gGlobals = GetGlobalStorage();
  201.  
  202.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIDInitAddr != (Ptr) nil )
  203.         anErr = ((RegistryEntryIDInitProcPtr) (**gGlobals).RegistryEntryIDInitAddr) (id);
  204.     return anErr;
  205. }
  206.  
  207. /*-----------------------------------------------------------------------------*
  208.  
  209.     SafeRegistryCStrEntryLookup
  210.     
  211.     Desc:        Stub code for name registry routine 'RegistryCStrEntryLookup'
  212.  
  213.     In:            searchPointID - the RegEntryID to start searching from
  214.                 pathName - the cstring path of the entry to find
  215.                 foundEntry - where to store the found entry
  216.  
  217.     Out:        foundEntry - the RegEntryID of any found entry
  218.                 returns any errors which may have occur
  219.     
  220.     History:
  221.  
  222.     18 Mar 98    gp        Added.
  223.     
  224. *-----------------------------------------------------------------------------*/
  225. OSStatus SafeRegistryCStrEntryLookup( RegEntryID *searchPointID, RegCStrPathName *pathName, RegEntryID *foundEntry)
  226. {
  227.     OSStatus    anErr=-1;                // return value
  228.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  229.  
  230.     gGlobals = GetGlobalStorage();
  231.     
  232.     // now call it
  233.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryCStrEntryLookupAddr != (Ptr) nil )
  234.         anErr = ((RegistryCStrEntryLookupProcPtr) (**gGlobals).RegistryCStrEntryLookupAddr) (searchPointID, pathName, foundEntry);
  235.     return anErr;
  236. }
  237.  
  238. /*-----------------------------------------------------------------------------*
  239.  
  240.     SafeRegistryEntryIterateCreate
  241.     
  242.     Desc:        Stub code for name registry routine 'RegistryEntryIterateCreate'
  243.  
  244.     In:            id - pointer to a RegEntryIter to initialize
  245.  
  246.     Out:        returns any errors which may have occur
  247.     
  248.     History:
  249.  
  250.     18 Mar 98    gp        Added.
  251.     
  252. *-----------------------------------------------------------------------------*/
  253. OSStatus SafeRegistryEntryIterateCreate(RegEntryIter *cookie)
  254. {
  255.     OSStatus    anErr=-1;                // return value
  256.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  257.  
  258.     gGlobals = GetGlobalStorage();
  259.  
  260.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateCreateAddr != (Ptr) nil )
  261.         anErr = ((RegistryEntryIterateCreateProcPtr) (**gGlobals).RegistryEntryIterateCreateAddr) (cookie);
  262.     return anErr;
  263. }
  264.  
  265. /*-----------------------------------------------------------------------------*
  266.  
  267.     SafeRegistryEntryIterateDispose
  268.     
  269.     Desc:        Stub code for name registry routine 'RegistryEntryIterateDispose'
  270.  
  271.     In:            cookie - iterator to dispose
  272.  
  273.     Out:        returns any errors which may have occur
  274.     
  275.     History:
  276.  
  277.     18 Mar 98    gp        Added.
  278.     
  279. *-----------------------------------------------------------------------------*/
  280. OSStatus SafeRegistryEntryIterateDispose(RegEntryIter *cookie)
  281. {
  282.     OSStatus    anErr=-1;                // return value
  283.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  284.  
  285.     gGlobals = GetGlobalStorage();
  286.  
  287.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateDisposeAddr != (Ptr) nil )
  288.         anErr = ((RegistryEntryIterateDisposeProcPtr) (**gGlobals).RegistryEntryIterateDisposeAddr) (cookie);
  289.     return anErr;
  290. }
  291.  
  292. /*-----------------------------------------------------------------------------*
  293.  
  294.     SafeRegistryEntryIterateSet
  295.     
  296.     Desc:        Stub code for name registry routine 'RegistryEntryIterateSet'
  297.  
  298.     In:            cookie - pointer to iterator to set
  299.                 startEntryID - name registry entry to start iterating from
  300.  
  301.     Out:        returns any errors which may have occur
  302.     
  303.     History:
  304.  
  305.     18 Mar 98    gp        Added.
  306.     
  307. *-----------------------------------------------------------------------------*/
  308. OSStatus SafeRegistryEntryIterateSet(RegEntryIter *cookie, RegEntryID *startEntryID)
  309. {
  310.     OSStatus    anErr=-1;                // return value
  311.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  312.  
  313.     gGlobals = GetGlobalStorage();
  314.  
  315.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateSetAddr != (Ptr) nil )
  316.         anErr = ((RegistryEntryIterateSetProcPtr) (**gGlobals).RegistryEntryIterateSetAddr) (cookie, startEntryID);
  317.     return anErr;
  318. }
  319.  
  320. /*-----------------------------------------------------------------------------*
  321.  
  322.     SafeRegistryEntryIterate
  323.     
  324.     Desc:        Stub code for name registry routine 'RegistryEntryIterate'
  325.  
  326.     In:            cookie - iterator to use
  327.                 relationship - direction to iterate
  328.                 foundEntry - where to store next name entry found
  329.                 done - tells if we're done with iteration
  330.  
  331.     Out:        foundEntry - RegEntryID of name entry found
  332.                 done - true if no more entries found
  333.                 returns any errors which may have occur
  334.     
  335.     History:
  336.  
  337.     18 Mar 98    gp        Added.
  338.     
  339. *-----------------------------------------------------------------------------*/
  340. OSStatus SafeRegistryEntryIterate(RegEntryIter *cookie, RegEntryIterationOp relationship, 
  341.         RegEntryID *foundEntry, Boolean *done)
  342. {
  343.     OSStatus    anErr=-1;                // return value
  344.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  345.  
  346.     gGlobals = GetGlobalStorage();
  347.  
  348.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIterateAddr != (Ptr) nil )
  349.         anErr = ((RegistryEntryIterateProcPtr) (**gGlobals).RegistryEntryIterateAddr) (cookie, relationship, foundEntry, done);
  350.     return anErr;
  351. }
  352.  
  353. /*-----------------------------------------------------------------------------*
  354.  
  355.     SafeRegistryEntryIDDispose
  356.     
  357.     Desc:        Stub code for name registry routine 'RegistryEntryIDDispose'
  358.  
  359.     In:            id - RegEntryID to dispose
  360.  
  361.     Out:        returns any errors which may have occur
  362.     
  363.     History:
  364.  
  365.     18 Mar 98    gp        Added.
  366.     
  367. *-----------------------------------------------------------------------------*/
  368. OSStatus SafeRegistryEntryIDDispose(RegEntryID *id)
  369. {
  370.     OSStatus    anErr=-1;                // return value
  371.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  372.  
  373.     gGlobals = GetGlobalStorage();
  374.  
  375.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryEntryIDDisposeAddr != (Ptr) nil )
  376.         anErr = ((RegistryEntryIDDisposeProcPtr) (**gGlobals).RegistryEntryIDDisposeAddr) (id);
  377.     return anErr;
  378. }
  379.  
  380. /*-----------------------------------------------------------------------------*
  381.  
  382.     SafeRegistryPropertyGet
  383.     
  384.     Desc:        Stub code for name registry routine 'RegistryPropertyGet'
  385.  
  386.     In:            entryID - RegEntryID value that identifies a name entry
  387.                 propertyName - name of the property
  388.                 propertyValue - buffer to hold the property
  389.                 propertySize - size of the property buffer
  390.  
  391.     Out:        propertySize - size of the property retrieved
  392.                 returns any errors which may have occur
  393.     
  394.     History:
  395.  
  396.     18 Mar 98    gp        Added.
  397.     
  398. *-----------------------------------------------------------------------------*/
  399. OSStatus SafeRegistryPropertyGet( RegEntryID *entryID, RegPropertyName *propertyName, 
  400.         void *propertyValue, RegPropertyValueSize *propertySize)
  401. {
  402.     OSStatus    anErr=-1;                // return value
  403.     USBGlobalsHandle    gGlobals=nil;    // our global data area
  404.  
  405.     gGlobals = GetGlobalStorage();
  406.  
  407.     if( gGlobals != nil && (Ptr) (**gGlobals).RegistryPropertyGetAddr != (Ptr) nil )
  408.         anErr = ((RegistryPropertyGetProcPtr) (**gGlobals).RegistryPropertyGetAddr) (entryID, propertyName, propertyValue, propertySize);
  409.     return anErr;
  410. }
  411.  
  412. /*-----------------------------------------------------------------------------*
  413.  
  414.     GetSystemArchitecture
  415.     
  416.     Desc:        Taken from 
  417.                 DTS Technote 1077 "Calling CFM Code from Classic 68K Code".
  418.                 Returns architect of current cpu during runtime.
  419.  
  420.  
  421.     In:            archType - address of variable to hold architect type
  422.  
  423.     Out:        archType - returns architect of current cpu pointed by this variable
  424.                 Also returns any errors
  425.     
  426.     History:
  427.  
  428.     18 Mar 98    gp        Added.
  429.     
  430. *-----------------------------------------------------------------------------*/
  431.  
  432. pascal OSErr GetSystemArchitecture(OSType *archType)
  433. {
  434.     long sSysArchitecture = 0; // static so we only Gestalt once.
  435.     OSErr tOSErr = noErr;
  436.     
  437.     *archType = kAnyCFragArch;   // assume wild architecture
  438.     
  439.     // If we don't know the system architecture yet...
  440.     if (sSysArchitecture == 0)
  441.         // ...Ask Gestalt what kind of machine we are running on.
  442.         tOSErr = Gestalt(gestaltSysArchitecture, &sSysArchitecture);
  443.     
  444.     if (tOSErr == noErr) // if no errors
  445.     {
  446.         if (sSysArchitecture == gestalt68k)   // 68k?
  447.              *archType = kMotorola68KCFragArch;   
  448.         else if (sSysArchitecture == gestaltPowerPC) // PPC?
  449.              *archType = kPowerPCCFragArch;       
  450.         else
  451.              tOSErr = gestaltUnknownErr;  // who knows what might be next?
  452.     }
  453.     return tOSErr;
  454. }
  455.  
  456. /*-----------------------------------------------------------------------------*
  457.  
  458.     FindAddress
  459.     
  460.     Desc:        Taken from 
  461.                 DTS Technote 1077 "Calling CFM Code from Classic 68K Code".
  462.                 Returns the address of a routine in a shared library
  463.  
  464.     In:            pSymAddr - address of variable to hold returned address
  465.                 pSymName - a pstring of the name of the routine
  466.                 pProcInfo - stack descriptor for the routine
  467.  
  468.     Out:        pSymAddr - the address of the routine pointed by this variable
  469.                 Also returns any errors
  470.     
  471.     History:
  472.  
  473.     10 Jun 98    gp        Init the address ptr passed in before using it
  474.     9  Jun 98    gp        Use our connection id to the name registry instead of
  475.                         opening it every time
  476.     18 Mar 98    gp        Added.
  477.     
  478. *-----------------------------------------------------------------------------*/
  479.  
  480. OSErr FindAddress(Ptr* pSymAddr, Str255 pSymName, ProcInfoType pProcInfo)
  481. {
  482.     CFragConnectionID sCID = 0;
  483.     OSType sArchType = kAnyCFragArch;
  484.     OSErr sOSErr = noErr;
  485.     USBGlobalsHandle    gGlobals=nil;        // our global data area
  486.  
  487.     Str255 errMessage;
  488.     Ptr mainAddr;
  489.     CFragSymbolClass symClass;
  490.           ISAType tISAType;
  491.     
  492.     *pSymAddr = (Ptr) kUnresolvedCFragSymbolAddress;
  493.  
  494.     if( NameRegistryInstalled() == false )
  495.         return -1;            // return general error - gp
  496.     
  497.     gGlobals = GetGlobalStorage();
  498.  
  499.     if (sArchType == kAnyCFragArch)  // if architecture is undefined...
  500.     {
  501.         sCID = 0;     // ...force (re)connect to library
  502.         sOSErr = GetSystemArchitecture(&sArchType); // determine architecture
  503.         if (sOSErr != noErr)
  504.              return sOSErr; // OOPS!
  505.     }
  506.     
  507.     if (sArchType == kMotorola68KCFragArch) // ...for CFM68K
  508.           tISAType = kM68kISA | kCFM68kRTA;
  509.     else if (sArchType == kPowerPCCFragArch)  // ...for PPC CFM
  510.           tISAType = kPowerPCISA | kPowerPCRTA;
  511.     else
  512.         sOSErr = gestaltUnknownErr; // who knows what might be next?
  513.     
  514.      sCID = (**gGlobals).sCID;
  515.     if (sCID == 0) // If we haven't connected to the library yet...
  516.     {
  517.         // NOTE: The library name is hard coded here.
  518.         // I try to isolate the glue code, one file per library.
  519.         // I have had developers pass in the Library name to allow
  520.         // plug-in type support. Additional code has to be added to
  521.         // each entry points glue routine to support multiple or
  522.         // switching connection IDs.
  523.         sOSErr = GetSharedLibrary("\pNameRegistryLib", sArchType, kLoadCFrag,
  524.                    &sCID, &mainAddr, errMessage);
  525.         if (sOSErr != noErr)
  526.              return sOSErr; // OOPS!
  527.          (**gGlobals).sCID = sCID;            // save connection id
  528.     }
  529.     
  530.     // If we haven't looked up this symbol yet...
  531.     if ((Ptr) *pSymAddr == (Ptr) kUnresolvedCFragSymbolAddress)    
  532.     {
  533.         // ...look it up now
  534.         sOSErr = FindSymbol(sCID,pSymName,pSymAddr,&symClass);
  535.         if (sOSErr != noErr) {// in case of error...
  536.          // ...clear the procedure pointer
  537.              *pSymAddr = (Ptr) kUnresolvedCFragSymbolAddress;
  538.         }
  539.         #if !GENERATINGCFM // if this is classic 68k code...
  540.          *pSymAddr = (Ptr)NewRoutineDescriptorTrap((ProcPtr) *pSymAddr,
  541.                       pProcInfo, tISAType);  // ...create a routine descriptor...
  542.         #endif
  543.     }
  544.     return sOSErr;
  545. }
  546.  
  547. /*-----------------------------------------------------------------------------*
  548.  
  549.     InitNameRegistryPtrs
  550.     
  551.     Desc:        Create all the proc ptrs to Name Registry calls we will
  552.                 need
  553.  
  554.     In:            None
  555.  
  556.     Out:        None
  557.     
  558.     History:
  559.  
  560.     10 Jun 98    gp        Use a local variable to store the routine address
  561.     9  Jun 98    gp        Init our connection id to the name registry
  562.     25 Mar 98    gp        Created
  563.     
  564. *-----------------------------------------------------------------------------*/
  565. void    InitNameRegistryPtrs( void )
  566. {
  567.     USBGlobalsHandle    gGlobals = nil;        // our global data area
  568.     Ptr                    address = nil;
  569.  
  570.     gGlobals = GetGlobalStorage();
  571.  
  572.     if( gGlobals != nil && NameRegistryInstalled() == true) {
  573.         (**gGlobals).sCID = 0;
  574.  
  575.         FindAddress( (Ptr*) &address, 
  576.                 "\pRegistryEntryIDInit", kRegistryEntryIDInitProcInfo );
  577.         (**gGlobals).RegistryEntryIDInitAddr = (ProcPtr) address;
  578.  
  579.         FindAddress( (Ptr*) &address, 
  580.                 "\pRegistryCStrEntryLookup", kRegistryCStrEntryLookupProcInfo );
  581.         (**gGlobals).RegistryCStrEntryLookupAddr = (ProcPtr) address;
  582.  
  583.         FindAddress( (Ptr*) &address, 
  584.                 "\pRegistryEntryIterateCreate", kRegistryEntryIterateCreateProcInfo );
  585.         (**gGlobals).RegistryEntryIterateCreateAddr = (ProcPtr) address;
  586.  
  587.         FindAddress( (Ptr*) &address, 
  588.                 "\pRegistryEntryIterateDispose", kRegistryEntryIterateDisposeProcInfo );
  589.         (**gGlobals).RegistryEntryIterateDisposeAddr = (ProcPtr) address;
  590.  
  591.         FindAddress( (Ptr*) &address, 
  592.                 "\pRegistryEntryIterateSet", kRegistryEntryIterateSetProcInfo );
  593.         (**gGlobals).RegistryEntryIterateSetAddr = (ProcPtr) address;
  594.  
  595.         FindAddress( (Ptr*) &address, 
  596.                 "\pRegistryEntryIterate", kRegistryEntryIterateProcInfo );
  597.         (**gGlobals).RegistryEntryIterateAddr = (ProcPtr) address;
  598.  
  599.         FindAddress( (Ptr*) &address, 
  600.                 "\pRegistryEntryIDDispose", kRegistryEntryIDDisposeProcInfo );
  601.         (**gGlobals).RegistryEntryIDDisposeAddr = (ProcPtr) address;
  602.  
  603.         FindAddress( (Ptr*) &address, 
  604.                 "\pRegistryPropertyGet", kRegistryPropertyGetProcInfo );
  605.         (**gGlobals).RegistryPropertyGetAddr = (ProcPtr) address;
  606.     }
  607. }
  608.  
  609. /*-----------------------------------------------------------------------------*
  610.  
  611.     RemoveNameRegistryPtrs
  612.     
  613.     Desc:        Remove all the proc ptrs we created for Name Registry calls
  614.  
  615.     In:            None
  616.  
  617.     Out:        None
  618.     
  619.     History:
  620.  
  621.     9  Jun 98    gp        Close our connection id to the name registry
  622.                         Use DisposeRoutineDescriptorTrap when disposing of the
  623.                         name registry routine descriptors
  624.     25 Mar 98    gp        Created
  625.     
  626. *-----------------------------------------------------------------------------*/
  627. void    RemoveNameRegistryPtrs(void)
  628. {
  629.     USBGlobalsHandle    gGlobals=nil;        // our global data area
  630.     CFragConnectionID sCID;
  631.  
  632.     
  633.     gGlobals = GetGlobalStorage();
  634.     if( gGlobals != nil ) {
  635.         // dispose of proc ptrs
  636.         
  637.         if( (**gGlobals).RegistryEntryIDInitAddr != nil )
  638.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIDInitAddr);
  639.         
  640.         if( (**gGlobals).RegistryCStrEntryLookupAddr != nil )
  641.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryCStrEntryLookupAddr);
  642.         
  643.         if( (**gGlobals).RegistryEntryIterateCreateAddr != nil )
  644.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateCreateAddr);
  645.         
  646.         if( (**gGlobals).RegistryEntryIterateDisposeAddr != nil )
  647.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateDisposeAddr);
  648.         
  649.         if( (**gGlobals).RegistryEntryIterateSetAddr != nil )
  650.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateSetAddr);
  651.         
  652.         if( (**gGlobals).RegistryEntryIterateAddr != nil )
  653.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIterateAddr);
  654.         
  655.         if( (**gGlobals).RegistryEntryIDDisposeAddr != nil )
  656.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryEntryIDDisposeAddr);
  657.         
  658.         if( (**gGlobals).RegistryPropertyGetAddr != nil )
  659.             DisposeRoutineDescriptorTrap( (**gGlobals).RegistryPropertyGetAddr);
  660.  
  661.         sCID = (**gGlobals).sCID;
  662.         CloseConnection( &sCID );
  663.     }
  664. }
  665.